   <html><head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
	</head>
	<body style="background-color: #76B5CD;">
	

<script type="text/javascript" src="http://prototypejs.org/assets/2009/6/16/prototype.js"></script>

   <script type="text/javascript">
	 
	 
	 function callKinesys () {
	 window.open("http://www.valeo.com", "valeo", 'left=20,top=20,width=500,height=500,toolbar=0,resizable=1,location=0,scrollbars=1');
	 }
	 
	function hideAuth () {
	document.getElementById("Authentication").style.display="none";
	}
	
	function showAuth () {
	document.getElementById("Authentication").style.display="";
	}
	
	 function openAjax () {
	 var req = null; 
	 	if (window.XMLHttpRequest)
		{
 			req = new XMLHttpRequest();

		} 
		else if (window.ActiveXObject) 
		{
			try {
				req = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e)
			{
				try {
					req = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {alert ("browser not supported");}
			}
        }
			
	return req;
	 }
	 
	function displayGreeting () {
		var textURL = "";
		textURL += "https://10.111.74.20/valeo/K_Directory.nsf/a_wagent?openagent&p1=";
		textURL += "COSTE";
		textURL += "&p2=";
		textURL += "&p3=";
		
	 //window.open(textURL,'mywin','left=20,top=20,width=500,height=500,toolbar=0,resizable=1,location=0,scrollbars=1');
 
	var req = openAjax();
		document.ajax.dyn.value="Started...";

		req.onreadystatechange = function()
		{ 
			document.ajax.dyn.value="Wait server..." +req.readyState;
			if(req.readyState == 4)
			{
				if(req.status == 200)
				{
					document.ajax.dyn.value="Received:" + req.responseText;	
				}	
				else	
				{
					if(req.status == 0)
					{
						document.ajax.dyn.value="Authentification requise" + req.status + "|" + req.statusText;
						alert(req.responseText);
						showAuth ();
					}
					else
					{
						document.ajax.dyn.value="Error:" + req.status + "|" + req.statusText;
					}	
				}
			} 
		};
		
		req.open("GET", textURL, true, "Sebastien.COSTE", "password"); 
		req.send(null); 
	} 
	
	function authenticate () {

	var reqAuth = openAjax();
	document.ajax.dyn.value="Auth started...";

		reqAuth.onreadystatechange = function()
		{ 
			document.ajax.dyn.value="Wait server...";
			if(reqAuth.readyState == 4)
			{
				if(reqAuth.status == 200)
				{
					hideAuth();
				}	
				else	
				{
					document.ajax.dyn.value="Authentication error:" + reqAuth.status + "|" + reqAuth.statusText;	
				}
			} 
		}; 
		reqAuth.open("GET", textURL, true, document.getElementById("login").value, document.getElementById("password").value ); 
		reqAuth.send(null); 
	
	}

	</script> 
	<table><tr><td>
	<img src="http://vd-gadget.googlecode.com/svn-history/r46/trunk/Kinesys.JPG" alt="Kinesys" onclick="callKinesys()">
	</td><td>&#160&#160&#160&#160</td><td align="middle"><p style="font-size:20px;"><b>TEST AJAX</b></p>
	</td></tr></table>
	
	<div id="Authentication" style="display:none">
	<p>
	Veuillez vous authentifier pour vous connecter au serveur valeo
	</p>
	<FORM name="Auth" method="POST" action="">
		<p>
		<input type="text" id="login" size="100" value="Login">
		</p>
		<p>
		<input type="text" id="password" size="100" value="password">
		</p>
		<p>
		<INPUT type="BUTTON" value="Submit"  ONCLICK="authenticate()">
		</p>
	</FORM>
	</div>
	
<FORM name="ajax" method="POST" action="">

		<p>
		<INPUT type="BUTTON" value="Submit"  ONCLICK="displayGreeting()">
		</p>
		<p>
		<input type="text" name="dyn" size="100" value="">
		</p>
	</FORM>




   </body></html>

   